package cn.byapps.attendance.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.byapps.attendance.dao.FavJobDao;
import cn.byapps.attendance.entity.FavJob;
import core.dao.impl.BaseDaoImpl;

@Repository
public class FavJobDaoImpl extends BaseDaoImpl<FavJob> implements FavJobDao {

	@Override
	public List getGroupByDeptList(String dept,Integer records) {
		return this.sessionFactory.getCurrentSession().createQuery("select s.firstJob,count(s.firstJob) as num from FavJob s where s.student.dept=:dept group by s.firstJob order by num desc").setParameter("dept", dept).setFirstResult(0).setMaxResults(records).list();
	}

	@Override
	public List getGroupByList(Integer records) {
		return this.sessionFactory.getCurrentSession().createQuery("select s.firstJob,count(s.firstJob) as num from FavJob s group by s.firstJob order by num").setFirstResult(0).setMaxResults(records).list();
	}

	@Override
	public List getGroupByClazzList(String clazz, Integer records) {
		return this.sessionFactory.getCurrentSession().createQuery("select s.firstJob,count(s.firstJob) as num from FavJob s where s.student.clazz=:clazz group by s.firstJob order by num desc").setParameter("clazz", clazz).setFirstResult(0).setMaxResults(records).list();
	}

}
